import config from '../../etc/config'
// pages/accounts-detail/index.js

const {$Toast} = require('../../components/dist/base/index');
Page({

  /**
   * 页面的初始数据
   */

  data: {
    current: '1',
    deId: '',
    currentPage: 1,
    getSettList: {}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    wx.hideShareMenu()
    this.setData({
      deId: options.deId
    })
    // this.getSettList(1)
  },
  getSettList(key) {
    let params = {
      deId: this.data.deId,
      status: key,
      current: this.data.currentPage,
      size: 10
    }
    let token = wx.getStorageSync('token')
    config._post('/deliverymansett/getSettList', token, params).then(res => {
      wx.stopPullDownRefresh()
      if (res.data.records.length>0) {
        for (let i = 0; i < res.data.records.length;i++){
          this.data.getSettList.push(res.data.records[i])
        }
        this.setData({
          getSettList: this.data.getSettList,
        })
      }
    })
  },
  handleChange(e) {
    this.setData({
      current: e.detail.key,
      getSettList:[],
      currentPage:1
    })
    this.getSettList(e.detail.key)
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.setData({
      getSettList: [],
      currentPage: 1
    })
    this.getSettList(this.data.current)
  },


  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {
    this.data.currentPage = 1
    this.setData({
      getSettList: []
    })
    this.getSettList(this.data.current)
  },


  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {
    this.data.currentPage += 1
    this.getSettList(this.data.current)
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {


  }
})